/*
 * @lc app=leetcode.cn id=200 lang=javascript
 *
 * [200] 岛屿数量
 */

// @lc code=start
/**
 * @param {character[][]} grid
 * @return {number}
 */
var numIslands = function(grid) {
  let total = 0
  const rowSize=grid.length
  const colSize = grid[0].length
  const dfs = (target) => {
    const queque = [target]
    while (queque.length) {
      const { row, col } = queque.shift()
      if (row < 0 || col < 0 || row >= rowSize || col >= colSize) {
        continue
      }
      grid[row][col] === '2'
      queque.push({row:row-1,col})
      queque.push({row:row,col:col+1})
      queque.push({row:row+1,col:col})
      queque.push({row:row,col:col-1})
    }
  }
  for (let row = 0; row < rowSize; row++){
    for (let col = 0; col < colSize; col++){
      if (grid[row][col] === '1') {
        total++
        dfs({row,col})
      }
    }
  }
console.log(total)
 return total
};
// @lc code=end

